import React, { Component } from 'react';
import FieldItem from './FieldItem';

export default class FieldList extends Component {
  render() {
    const{fieldItems,iconClick,contentClick} = this.props;
    let items = [];
    fieldItems && fieldItems.forEach((item,index) => {  
        let itemProps = {
            ...item
        };
        if(item.iconType){
            itemProps.iconType = item.iconType;
        }
        if(iconClick){
            itemProps.iconClick = iconClick;
        }    
        if(contentClick){
            itemProps.contentClick = contentClick;
        }     
        const showBottom = (index < fieldItems.length - 1);
        items.push(
            <FieldItem
                {...itemProps}
                itemKey={item.key}
                showBottom={showBottom}
            />
        );
    });

    return (        
      <div>
        {items}
      </div>
    );
  }
}